import { ValidateStringNumber } from '@/common/decorators/validate-string-number.decorator';
import { ApiProperty } from '@nestjs/swagger';
import {
  IsEmail,
  IsNotEmpty,
  IsOptional,
  IsPhoneNumber,
  IsString,
  MaxLength,
  MinLength,
} from 'class-validator';

export class CreateUserDto {
  @ApiProperty({ name: '用户名', type: String })
  @IsNotEmpty({ message: '用户名不能为空' })
  @MaxLength(32, { message: '用户名长度不能超过32个字符' })
  @MinLength(1, { message: '用户名长度不能小于1个字符' })
  name: string;

  @ApiProperty({ name: '密码', type: String })
  @MinLength(6, { message: '密码长度不能小于6个字符' })
  @IsNotEmpty({ message: '密码不能为空' })
  password: string;

  @ApiProperty({ name: '头像', type: String })
  @IsString({ message: '头像必须是字符串' })
  @IsOptional()
  avatar: string;

  @ApiProperty({ name: '邮箱', example: '123@qq.com' })
  @IsNotEmpty({ message: '邮箱不能为空' })
  @IsEmail({}, { message: '邮箱格式不正确' })
  email: string;

  @ApiProperty({ name: '手机号码', example: 12345678901 })
  @ValidateStringNumber({ message: '手机号码必须是字符串或者数字' })
  @IsPhoneNumber('CN', { message: '手机号码格式不正确' })
  @IsOptional()
  phone: string;

  @ApiProperty({ name: 'ip' })
  @IsOptional()
  ip: string;

}
